#include "client.h"

int main(int argc,char *argv[])
{
    ARGS_CHECK(argc,3);
    int sockfd=connect_net(argv[1],argv[2]);

    int epfd=epoll_create(1);

    add_epoll(epfd,sockfd);
    add_epoll(epfd,STDIN_FILENO);
    struct epoll_event readytp[1024];
    char buf[BUFFER_SIZE]={0};
    interface();
    int flat=0;
    while(!flat){
          printf("请输入账户:\n");      
         flat=enter(sockfd);
    }
    while(1){
        int num=epoll_wait(epfd,readytp,1024,-1);

        for(int i=0;i<num;i++){
            int netfd=readytp[i].data.fd;
            if(netfd==sockfd){
                //read(sockfd,buf,sizeof(buf));
                reiceive(netfd);
            }
            else{ 
                bzero(buf,sizeof(buf));
                read(STDIN_FILENO,buf,sizeof(buf));
                process_characters(sockfd,buf);
            }
        }
    }
    return 0;

}
